package cn.funnyxb.powerremember.uis.task;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import cn.funnyxb.powerremember.beans.ATask;
import cn.funnyxb.powerremember.pullMsg.beans.AppConfig;
import cn.funnyxb.powerremember.pullMsg.beans.VersionInfo;
import cn.funnyxb.powerremember.uis.task.taskEdit.TaskEditActivity;
import cn.funnyxb.tools.appFrame.App;
import cn.funnyxb.tools.appFrame.activityFrame.ActivitysHolder;
import cn.funnyxb.tools.appFrame.debugTool.Debuger;
import com.mobclick.android.MobclickAgent;

public class TasksActivity extends Activity
  implements IUI_Tasks
{
  private static final int MENUID_ABOUT = 20;
  private static final int MENUID_COMM = 10;
  private static final int MENUID_SHARE = 5;
  protected static final int REQUESTCODE_EDITTASK = 110;
  protected static final int REQUESTCODE_NEWTASK = 100;
  protected static final int REQUESTCODE_TASKMAIN = 120;
  private View.OnClickListener btnOnClickListener = new 1(this);
  private IProccessor_Tasks proccessor = null;
  private ProgressDialog progressDialog;
  private SimpleCursorAdapter sca = null;

  private void createSCA(Cursor paramCursor)
  {
    String[] arrayOfString = new String[1];
    arrayOfString[0] = "name";
    int[] arrayOfInt = new int[1];
    arrayOfInt[0] = 16908308;
    this.sca = new SimpleCursorAdapter(this, 17367043, paramCursor, arrayOfString, arrayOfInt);
    ((ListView)findViewById(2131165211)).setAdapter(this.sca);
    ((ListView)findViewById(2131165211)).setOnItemClickListener(new 4(this));
    ((ListView)findViewById(2131165211)).setOnCreateContextMenuListener(new 5(this));
  }

  private void createTask()
  {
    Intent localIntent = new Intent(this, TaskEditActivity.class);
    localIntent.putExtra("taskmode", 1);
    startActivityForResult(localIntent, 100);
  }

  private void delTask(ATask paramATask)
  {
    new AlertDialog.Builder(this).setTitle(2131034130).setMessage(2131034151).setPositiveButton(2131034154, new 6(this, paramATask)).setNegativeButton(2131034153, null).create().show();
  }

  private void eidtTask(ATask paramATask)
  {
    Intent localIntent = new Intent(this, TaskEditActivity.class);
    localIntent.putExtra("taskmode", 2);
    localIntent.putExtra("taskinfo", paramATask);
    startActivityForResult(localIntent, 110);
  }

  private void initAppConfig()
  {
    AppConfig localAppConfig = App.getApp().getAppConfig();
    if (!(localAppConfig.isValid()))
      notifyNotValidVersion();
    localAppConfig.regWatcher(new 2(this));
  }

  private void initFrame()
  {
    requestWindowFeature(1);
    setContentView(2130903044);
    findViewById(2131165207).setOnClickListener(this.btnOnClickListener);
    findViewById(2131165208).setOnClickListener(this.btnOnClickListener);
    findViewById(2131165209).setOnClickListener(this.btnOnClickListener);
    findViewById(2131165211).setBackgroundResource(17301654);
  }

  private void log(String paramString)
  {
    Debuger.log("ui_tasks", paramString);
  }

  private void notifyNotValidVersion()
  {
    new AlertDialog.Builder(this).setTitle(2131034130).setMessage(2131034170).setNegativeButton(2131034158, new 3(this)).create().show();
  }

  private void showAboutDialog()
  {
    new AlertDialog.Builder(this).setTitle("关于给力 V2.02 beta").setMessage(getString(2131034121) + "\n" + getString(2131034122) + "\n" + getString(2131034123) + "\n" + getString(2131034124)).setNegativeButton("知道了", null).create().show();
  }

  public void dismissWaitingDialog()
  {
    if (this.progressDialog == null)
      return;
    this.progressDialog.dismiss();
  }

  public void notifyTasksDataLoaded(Cursor paramCursor)
  {
    log("cursor=" + paramCursor);
    if ((isFinishing()) || (isRestricted()));
    while (true)
    {
      return;
      if ((paramCursor == null) || (paramCursor.getCount() == 0))
        showAboutDialog();
      Debuger.debugCursor("listcusor", paramCursor);
      dismissWaitingDialog();
      if (this.sca == null)
      {
        createSCA(paramCursor);
        ((ListView)findViewById(2131165211)).setAdapter(this.sca);
      }
      this.sca.changeCursor(paramCursor);
    }
  }

  public void notifyUpdate(VersionInfo paramVersionInfo)
  {
    log("showUpdate,isfinishing=" + isFinishing() + ",isRestricted()" + isRestricted());
    if ((paramVersionInfo == null) || (isFinishing()) || (isRestricted()));
    while (true)
    {
      return;
      WebView localWebView = new WebView(this);
      localWebView.loadDataWithBaseURL(null, paramVersionInfo.getVersionInfo_html(), "text/html", "utf-8", null);
      new AlertDialog.Builder(this).setTitle(paramVersionInfo.getVersionTitle()).setView(localWebView).setPositiveButton(2131034135, null).setNegativeButton(2131034134, null).create().show();
    }
  }

  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    super.onActivityResult(paramInt1, paramInt2, paramIntent);
    log("activityResult!");
  }

  public boolean onContextItemSelected(MenuItem paramMenuItem)
  {
    int i = ((AdapterView.AdapterContextMenuInfo)paramMenuItem.getMenuInfo()).position;
    ATask localATask = ATask.parseFromCursorOfTaskInfo((Cursor)this.sca.getItem(i));
    switch (paramMenuItem.getItemId())
    {
    case 2131165368:
    default:
    case 2131165366:
    case 2131165367:
    }
    while (true)
    {
      return super.onContextItemSelected(paramMenuItem);
      delTask(localATask);
      continue;
      eidtTask(localATask);
    }
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    log("create ,isTaskRoot=" + isTaskRoot());
    this.proccessor = new Proccessor_Tasks(this);
    initFrame();
    initAppConfig();
  }

  public boolean onCreateOptionsMenu(Menu paramMenu)
  {
    paramMenu.add(0, 5, 1, 2131034127);
    paramMenu.add(0, 10, 10, 2131034128);
    paramMenu.add(0, 20, 20, 2131034129);
    return super.onCreateOptionsMenu(paramMenu);
  }

  protected void onDestroy()
  {
    log("onDestroy");
    try
    {
      this.sca.getCursor().close();
      this.proccessor.destroy();
      App.getApp().destroy();
      super.onDestroy();
      return;
    }
    catch (Exception localException)
    {
    }
  }

  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    switch (paramMenuItem.getItemId())
    {
    default:
    case 5:
    case 10:
    case 20:
    }
    while (true)
    {
      return super.onOptionsItemSelected(paramMenuItem);
      Intent localIntent = new Intent("android.intent.action.SENDTO", Uri.parse("smsto:"));
      localIntent.putExtra("sms_body", getString(2131034125));
      startActivity(localIntent);
      continue;
      new AlertDialog.Builder(this).setTitle(2131034130).setMessage(2131034126).setNegativeButton(2131034158, null).create().show();
      continue;
      showAboutDialog();
    }
  }

  protected void onPause()
  {
    log("onPause");
    super.onPause();
    MobclickAgent.onPause(this);
  }

  protected void onRestart()
  {
    super.onRestart();
    log("onRestart");
  }

  protected void onResume()
  {
    super.onResume();
    log("onResume");
    MobclickAgent.onResume(this);
    App.getApp().getActivitysHolder().regCurrentActivity(this);
  }

  protected void onStart()
  {
    super.onStart();
    this.proccessor.asyncLoadTasksData();
    log("onStrart ,isTaskRoot=" + isTaskRoot());
  }

  protected void onStop()
  {
    super.onStop();
    log("onStop");
  }

  public void showWaitingDialog(String paramString1, String paramString2)
  {
    if (this.progressDialog == null)
      this.progressDialog = new ProgressDialog(this);
    if (paramString1 != null)
      this.progressDialog.setTitle(paramString1);
    if (paramString2 != null)
      this.progressDialog.setMessage(paramString2);
    this.progressDialog.setCancelable(false);
    this.progressDialog.show();
  }
}

/* Location:           E:\Desktop\复件 classes_dex2jar.jar
 * Qualified Name:     cn.funnyxb.powerremember.uis.task.TasksActivity
 * JD-Core Version:    0.5.3
 */